//枚举可以发现：第 n 阶的跳法 = 第 n-1 阶的跳法 + 第 n-2 阶的跳法
// f ( n ) = f ( n - 1 ) + f ( n - 2 )

function jump(n: number): number {
  if (n === 0) return 0;
  if (n === 1) return 1;
  let pre = 1;
  let cur = 1;
  for (let i = 2; i <= n; i++) {
    let newValue = pre + cur;
    pre = cur;
    cur = newValue;
  }

  return cur;
}

console.log(jump(3));

console.log(jump(4));
